//
//  TextPutView.m
//  STEmojiKeyboard
//
//  Created by 钓鱼人 on 16/2/22.
//  Copyright © 2016年 sTeven. All rights reserved.
//

#import "TextPutView.h"

@interface TextPutView ()<DidSendClickedDeleget>

@end

@implementation TextPutView

-(instancetype)initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        _inputBar = [STInputBar inputBar];
        _inputBar.center = CGPointMake(CGRectGetWidth(self.frame)/2, CGRectGetHeight(self.bounds)-CGRectGetHeight(_inputBar.frame)+CGRectGetHeight(_inputBar.frame)/2);
        [_inputBar setFitWhenKeyboardShowOrHide:YES];
        _inputBar.deleget = self;

        [self addSubview:_inputBar];
        
        /**
         *  给inputBart添加手势  让点击 inputBart 时 self.alpha != 0;
         */
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(TapTap)];
        [_inputBar addGestureRecognizer:tap];
        
        
        UITapGestureRecognizer *selfTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(SelfTap)];
        
        [self addGestureRecognizer:selfTap];
        
        self.backgroundColor = [UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:0.3];
        
    }
    return self;
}

-(void)setNoFace:(BOOL)NoFace{
    _NoFace = NoFace;
    
    
    if (_NoFace == YES) {
        _inputBar.NoFace = YES;
    }


}

-(void)SelfTap{

    self.alpha = 0;
    [self.inputBar resignFirstResponder];

}
-(void)TapTap{


}

/**
 * 点击发送代理方法
 */
-(void)DidSendClicked:(NSString *)sendText{
    self.alpha = 0;
    [self.inputBar resignFirstResponder];
    [self.deleget DidSender:sendText];
}
@end
